package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dao.WxCountersMapper;
import com.tencent.wxcloudrun.model.WxCounter;
import com.tencent.wxcloudrun.service.WxCounterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class WxCounterServiceImpl implements WxCounterService {

  final WxCountersMapper countersMapper;

  public WxCounterServiceImpl(@Autowired WxCountersMapper countersMapper) {
    this.countersMapper = countersMapper;
  }

  @Override
  public Optional<WxCounter> getCounter(Integer id) {
    return Optional.ofNullable(countersMapper.getCounter(id));
  }

  @Override
  public void upsertCount(WxCounter counter) {
    countersMapper.upsertCount(counter);
  }

  @Override
  public void clearCount(Integer id) {
    countersMapper.clearCount(id);
  }
}
